package viper.GUI;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

public class IconListRenderer extends DefaultListCellRenderer {

		private static final long serialVersionUID = 1L;

		@Override
		public Component getListCellRendererComponent(
				JList list, Object value, int index,
				boolean isSelected, boolean cellHasFocus) {

			if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
            } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            }
			
			JLabel label = (JLabel)value;
			label.setBackground(Color.WHITE);
			setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 16));
			setText(label.getText());
			setIcon(label.getIcon());
			return this;
		}

}
